<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <ul>
        <li class="one">1</li>
        <li class="one">2</li>
        <li class="one">3</li>
    </ul>
    <script>
        //除getelementbyId,getelementsbyClassName,getElementbyTagName之外的新获取方式，通过选择器获取
        var lis = document.querySelectorAll(".one");
        //选择器获取时一定要带上class的.
        console.log(lis);
        for(let i=0;i<lis.length;i++){
            lis[i].onclick = function(){
                for(let i=0;i<lis.length;i++){
                    lis[i].style.color="black";
                }
                this.style.color="red"
            }
            
        }

    </script>
</body>
</html>